/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.innovision.helper.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author PATO
 */
public class Formateador {
    private static final String FORMAT_DATE = "dd/MM/yyyy hh:mm:ss";
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat(FORMAT_DATE);
    private String project = null; 
    private String subsystem = null;
    private String pkgName = "cl.innovision";
    public Formateador(String project, String subsystem) {
		this.project = project;
		this.subsystem = subsystem;
                this.pkgName=this.pkgName+"."+project+"."+subsystem;
	}

	public static String firstToUpperCase(String str) {
		if (str == null || str.length() == 0) {
			return str;
		}
		String first = str.substring(0, 1);
		str = first.toUpperCase() + str.substring(1, str.length());
		return str;
	}

	public static String firstToLowerCase(String str) {
		if (str == null || str.length() == 0) {
			return str;
		}
		String first = str.substring(0, 1);
		str = first.toLowerCase() + str.substring(1, str.length());
		return str;
	}
        
        public static String eliminaEspaciosEnBlanco(String str) {
		if (str == null || str.length() == 0) {
			return str;
		}
                for(int i=0;str.length()>i++;i++)
                {
                   
                }
		String first = str.substring(0, 1);
		str = first.toUpperCase() + str.substring(1, str.length());
		return str;
	}
        
        public static String date2string(Date date) {
		if (date == null) {
			return null;
		}
		return dateFormat.format(date);
	}

	public static Date string2date(String date) {
		if (date == null) {
			return null;
		}
		Date dt = null;

		try {
			dt = dateFormat.parse(date);
		} catch (ParseException excpt) {
			return null;
		}
		return dt;
	}
        public static java.sql.Date string2SQLdate(String date) {
		if (date == null) {
			return null;
		}
		java.sql.Date dt = null;

		try {
			dt = new java.sql.Date(dateFormat.parse(date).getTime());
		} catch (ParseException excpt) {
			return null;
		}
		return dt;
	}
        
	public String getProject() {
		return project;
	}

	public String getSubsystem() {
		return subsystem;
	}

    public String getPkgName() {
        return pkgName;
    }
        
}
